/**
* @name: MainView
* @author: D
* @date: 2022/8/4 15:02
* @description：MainView
* @update: 2022/8/4 15:02
*/
<template>
  <div class="wrap">
    <!--播放器主体-->
    <div class="play_wrap" id="player">
      <!--  歌曲搜索    -->
      <div class="play_wrap_header">
        <com-search @getSearchList="getSearchList($event)"/>
      </div>
      <div class="play_wrap_main">
        <div class="center_con">
          <div class="song_wrapper">
            <ul class="song_list">
              <li  v-for="item in musicList" :key="item.id">
                <a href="javascript:;" @click='playMusic(item.id)'></a>
                <b>{{item.name}}</b>
                <span><i></i></span>
              </li>
            </ul>
            <img src="~@/assets/images/line.png" class="switch_btn" alt="">
          </div>
          <!--  歌曲信息容器        -->
          <div class="player_con">
            <img src="~@/assets/images/player_bar.png" class="play_bar"/>
            <!-- 黑胶碟片 -->
            <img src="~@/assets/images/disc.png" class="disc autoRotate"/>
            <img class="cover autoRotate"/>
          </div>
          <!--评论容器-->
          <div class="comment_wrapper">
            <h5 class='title'>热门留言</h5>
            <div class='comment_list'>
              <dl>
                <dt><img src="~@/assets/images/table.png" alt=""></dt>
                <dd class="name">小明</dd>
                <dd class="detail">
                  真的赞
                </dd>
              </dl>
            </div>
            <img src="~@/assets/images/line.png" class="right_line">
          </div>
        </div>
        <div class="audio_con">
          <audio ref='audio' @play="play" @pause="pause" src="" controls autoplay loop class="myaudio"></audio>
        </div>
        <div class="video_con" v-show="isShow" style="display: none;">
          <video src="" controls="controls"></video>
          <div class="mask" @click="hide"></div>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import comSearch from "@/components/ComSearch";

export default {
  name: 'MainView',
  components: {
    comSearch
  },

  data() {
    return {
      //歌曲列表
      musicList: [],
      //是否正在播放
      isPlay: false,
      //mv 地址
      mvUrl: ''

    }
  },
  methods: {
    getSearchList(list) {
      //获取到搜索列表
      this.musicList = list
    },
    //audio 的 play 事件
    play() {
      this.isPlay = true
      //清空mv 的信息
      this.mvUrl = ''
    },
    //audio 的pause 事件
    pause() {
      this.isPlay = false
    }
  }
}
</script>

<style scoped lang="scss">
.wrap {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: url("~@/assets/images/bg.jpg") no-repeat;
  background-size: 100% 100%;
}

.play_wrap {
  width: 800px;
  height: 544px;
  position: fixed;
  left: 45%;
  top: 50%;
  margin-left: -400px;
  margin-top: -272px;
}

.center_con {
  height: 435px;
  background-color: rgba(255, 255, 255, 0.5);
  display: flex;
  position: relative;
}

.song_wrapper {
  width: 220px;
  height: 435px;
  box-sizing: border-box;
  padding: 10px;
  list-style: none;
  position: absolute;
  left: 0px;
  top: 0px;
  z-index: 1;
}

.song_stretch {
  width: 600px;
}

.song_list {
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  cursor: pointer;

  li {
    font-size: 12px;
    color: #333;
    height: 40px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 600px;
    padding-left: 20px;

    a {
      display: block;
      width: 17px;
      height: 17px;
      background-image: url("~@/assets/images/play.png");
      background-size: 100%;
      margin-right: 5px;
      box-sizing: border-box;
    }

    b {
      font-weight: normal;
      width: 122px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}

.song_list::-webkit-scrollbar {
  display: none;
}

.song_list li:nth-child(odd) {
  background-color: rgba(240, 240, 240, 0.3);
}

.song_stretch .song_list li b {
  width: 200px;
}

.song_stretch .song_list li em {
  width: 150px;
}

.song_list li span {
  width: 23px;
  height: 17px;
  margin-right: 50px;
}

.song_list li span i {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  background: url("~@/assets/images/table.png") left -48px no-repeat;
}

.song_list li em,
.song_list li i {
  font-style: normal;
  width: 100px;
}

.player_con {
  width: 400px;
  height: 435px;
  position: absolute;
  left: 200px;
  top: 0px;

  .play_bar {
    position: absolute;
    left: 200px;
    top: -10px;
    z-index: 10;
    transform: rotate(-25deg);
    transform-origin: 12px 12px;
    transition: 1s;
  }

  .disc {
    position: absolute;
    left: 73px;
    top: 60px;
    z-index: 9;
  }

  .cover {
    position: absolute;
    left: 125px;
    top: 112px;
    width: 150px;
    height: 150px;
    border-radius: 75px;
    z-index: 8;
  }
}

/* 旋转的动画 */
@keyframes Rotate {
  from {
    transform: rotateZ(0);
  }
  to {
    transform: rotateZ(360deg);
  }
}

/* 旋转的类名 */
.autoRotate {
  animation-name: Rotate;
  animation-iteration-count: infinite;
  animation-play-state: paused;
  animation-timing-function: linear;
  animation-duration: 5s;
}

/* 是否正在播放 */
.player_con.playing .disc,
.player_con.playing .cover {
  animation-play-state: running;
}

/* 播放杆 转回去 */
.player_con.playing .play_bar {
  transform: rotate(0);
}

.comment_wrapper {
  width: 180px;
  height: 435px;
  list-style: none;
  position: absolute;
  left: 600px;
  top: 0px;
  padding: 25px 10px;

  .title {
    position: absolute;
    top: 0;
    margin-top: 10px;
  }

  .comment_list {
    overflow: auto;
    height: 410px;
  }

  dl {
    padding-top: 10px;
    padding-left: 55px;
    position: relative;
    margin-bottom: 20px;
  }

  dt {
    position: absolute;
    left: 4px;
    top: 10px;

    img {
      width: 40px;
      height: 40px;
      border-radius: 20px;
    }
  }

  dd {
    font-size: 12px;
  }

  .name {
    font-weight: bold;
    color: #333;
    padding-top: 5px;
  }

  .detail {
    color: #666;
    margin-top: 5px;
    line-height: 18px;
  }
}

.comment_wrapper .comment_list::-webkit-scrollbar {
  display: none;
}

.audio_con {
  height: 50px;
  background-color: #f1f3f4;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.myaudio {
  width: 800px;
  height: 40px;
  margin-top: 5px;
  outline: none;
  background-color: #f1f3f4;
}

.video_con {
  video {
    position: fixed;
    width: 800px;
    height: 546px;
    left: 50%;
    top: 50%;
    margin-top: -273px;
    transform: translateX(-50%);
    z-index: 990;
  }

  .mask {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 980;
    background-color: rgba(0, 0, 0, 0.8);
  }

  .shutoff {
    position: fixed;
    width: 40px;
    height: 40px;
    background: url("~@/assets/images/shutoff.png") no-repeat;
    left: 50%;
    margin-left: 400px;
    margin-top: -273px;
    top: 50%;
    z-index: 995;
  }
}

</style>
